﻿using System;
using System.Windows.Forms;
using math.Controllers;
using math.DTOs;
using math.Views;

namespace MVPDemoWin
{
    public partial class Arith : Form, IArith
    {
        private ArithController _controller;
        public Arith()
        {
            InitializeComponent();
            _controller = new ArithController(this);
        }

        private void btnFactorial_Click(object sender, EventArgs e)
        {
            #region Old Style
            //int n = Convert.ToInt32(txtNo1.Text);
            //long fact = 1;
            //while (n >= 1)
            //{
            //    fact = fact * n;
            //    n--;
            //}
            //lblFact.Text = "Factorial is " + fact;
            #endregion

            _controller.HandleFactorial();


        }

        #region IArith Members

        public int InputNumber
        {
            get { return Convert.ToInt32(txtNo1.Text); }
        }

        public FactorialInfo Result
        {
            set { lblFact.Text = "Factorial of " + value.No + " is" + value.Fact; }
        }

        #endregion
    }
}
